package cbbx_sm.parser;

import java.util.List;
import java.util.Vector;

import cbbx_sm.utils.Timestamp;

/**
 * This class contains information about one processed frame, such as
 * timestamp and list of entities.
 * 
 * @author Alessio Della Motta - University of California, Irvine
 */
public class Frame implements Comparable<Frame> {
	private String cameraId;
	private String imageFilename;
	private Timestamp timestamp;
	private List<Entity> entities = null;
	
	public Frame(String imageFilename, Timestamp timestamp, List<Entity> entities, String cameraId){
		if (entities == null) this.entities = new Vector<Entity>();
		else this.entities = entities;
		this.imageFilename = imageFilename;
		this.timestamp = timestamp;
		this.cameraId = cameraId;
	}
	
	@Override
	public int compareTo(Frame o) {
		Frame frame = (Frame) o;
		return timestamp.compareTo(frame.timestamp);
	}
	
	@Override
	public boolean equals(Object o){
		if (!(o instanceof Frame)) return false;
		
		Frame frame = (Frame) o;
		return this.timestamp == frame.getTimestamp();
	}
	
	@Override
	public String toString(){
		StringBuffer str = new StringBuffer();
		str.append("Image-Filename: " + imageFilename + "\n");
		str.append("Timestamp: " + timestamp + "\n");
		str.append("Entities:\n" + entities.toString() + "\n\n");
		
		return str.toString();
	}

	public String getImageFilename() {
		return imageFilename;
	}

	public Timestamp getTimestamp() {
		return timestamp;
	}

	public List<Entity> getEntities() {
		return entities;
	}
	
	public String getCameraId() {
		return cameraId;
	}
	
	public void setCameraId(String cameraId) {
		this.cameraId = cameraId;
	}

	public void setImageFilename(String imageFilename) {
		this.imageFilename = imageFilename;
	}

	public void setEntities(List<Entity> entities) {
		this.entities = entities;
	}
}
